package com.ilearnjava.dubbo;

import com.alibaba.dubbo.common.extension.ExtensionLoader;
import com.alibaba.dubbo.rpc.Protocol;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * Hello world!
 *
 */
public class App 
{
    public static void main( String[] args )
    {
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("dubbo-client.xml");
        context.start();

        // 得到IGpHello的远程代理对象
        IGpHello gpHelloService = (IGpHello) context.getBean("gpHelloService");
        System.out.println(gpHelloService.sayHello("Dubbo"));

        // 自定义协议
        Protocol protocol = ExtensionLoader.getExtensionLoader(Protocol.class)
                .getExtension("myProtocol");

        System.out.println(protocol.getDefaultPort());

        System.out.println(ExtensionLoader.getExtensionLoader(Protocol.class).getDefaultExtension().getDefaultPort());

    }
}
